/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package reportcenter.datasource.dominio;

import reportcenter.report.dominio.report.Report;
import test.*;
import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import reportcenter.support.resourceload.DBDriver;

/**
 *
 * @author renan_luz
 */
@Entity
@Table(name = "DATA_SOURCE")
@NamedQueries({@NamedQuery(name = "DataSource.findByIdD", query = "SELECT d FROM DataSource d WHERE d.idD = :idD"), @NamedQuery(name = "DataSource.findByUsu", query = "SELECT d FROM DataSource d WHERE d.usu = :usu"), @NamedQuery(name = "DataSource.findByPass", query = "SELECT d FROM DataSource d WHERE d.pass = :pass"), @NamedQuery(name = "DataSource.findByUri", query = "SELECT d FROM DataSource d WHERE d.uri = :uri"), @NamedQuery(name = "DataSource.findByMinpool", query = "SELECT d FROM DataSource d WHERE d.minpool = :minpool"), @NamedQuery(name = "DataSource.findByMaxpool", query = "SELECT d FROM DataSource d WHERE d.maxpool = :maxpool"), 
               @NamedQuery(name = "DataSource.findAll", query = "SELECT d FROM DataSource d")})
public class DataSource implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "ID_D", nullable = false)
    private Integer idD;
    @Column(name = "USU", nullable = false)
    private String usu;
    @Column(name = "PASS", nullable = false)
    private String pass;
    @Column(name = "URI", nullable = false)
    private String uri;
    @Column(name = "MINPOOL", nullable = false)
    private int minpool;
    @Column(name = "MAXPOOL", nullable = false)
    private int maxpool;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idD")
    private Collection<Report> reportCollection;
    @Column(name = "NAME", nullable= false)
    private String name;
    @Column(name = "DRIVER", nullable= false)
    private String driver;
    

    public DataSource() {
    }

    public DataSource(Integer idD) {
        this.idD = idD;
    }

    public DataSource(Integer idD, String usu, String pass, String uri, int minpool, int maxpool) {
        this.idD = idD;
        this.usu = usu;
        this.pass = pass;
        this.uri = uri;
        this.minpool = minpool;
        this.maxpool = maxpool;
    }

    public Integer getIdD() {
        return idD;
    }

    public void setIdD(Integer idD) {
        this.idD = idD;
    }

    public String getUsu() {
        return usu;
    }

    public void setUsu(String usu) {
        this.usu = usu;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public int getMinpool() {
        return minpool;
    }

    public void setMinpool(int minpool) {
        this.minpool = minpool;
    }

    public int getMaxpool() {
        return maxpool;
    }

    public void setMaxpool(int maxpool) {
        this.maxpool = maxpool;
    }

    public Collection<Report> getReportCollection() {
        return reportCollection;
    }

    public void setReportCollection(Collection<Report> reportCollection) {
        this.reportCollection = reportCollection;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idD != null ? idD.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DataSource)) {
            return false;
        }
        DataSource other = (DataSource) object;
        if ((this.idD == null && other.idD != null) || (this.idD != null && !this.idD.equals(other.idD))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.DataSource[idD=" + idD + "]";
    }
}
